package com.example.composedemo.widget

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.example.generator.R

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun TextFieldTest() {
    var text by remember { mutableStateOf("Hello world") }

    TextField(
        value = text,
        onValueChange = {
            text = it
        },
        label = {
            Text(text = "我是标签")
        },
        leadingIcon = {
            Icon(imageVector = Icons.Filled.AccountBox, contentDescription = "用户名")
        },
        trailingIcon = {
            IconButton(onClick = { }) {
                Icon(painter = painterResource(id = R.drawable.ic_launcher_foreground), contentDescription = "尾部图标")
            }
        }
    )
}